package com.xingongchang.baolebei.activity;


import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import com.umeng.analytics.MobclickAgent;
import com.umeng.message.PushAgent;
import com.xingongchang.baolebei.R;

public class StartActivity extends Activity {
	private Context context;
	private PushAgent agent;

	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		final View startView = View.inflate(this, R.layout.splash, null);
		setContentView(startView);
		MobclickAgent.openActivityDurationTrack(false);
		MobclickAgent.onError(this);
		context = this;
		agent=PushAgent.getInstance(StartActivity.this);
		agent.enable();
		agent.setDebugMode(false);
		
		// 渐变
		AlphaAnimation aa = new AlphaAnimation(0.3f, 1.0f);
		aa.setDuration(2000);
		startView.setAnimation(aa);
		aa.setAnimationListener(new AnimationListener() {

			@Override
			public void onAnimationStart(Animation animation) {
			}

			@Override
			public void onAnimationRepeat(Animation animation) {
			}

			@Override
			public void onAnimationEnd(Animation animation) {
				redirectto();
			}
		});
	}

	private void redirectto() {
		Intent intent = new Intent(this, GalleryImageActivity.class);
		startActivity(intent);
		finish();
	}
}
